@extends('home.seller.layout.index')

@section('content')
	<div class="mws-panel grid_8 mws-collapsible">
    <div class="mws-panel-header">
        <span>
            <i class="icon-table">
            </i>
            商品列表
        </span>
        <div class="mws-collapse-button mws-inset">
            <span>
            </span>
        </div>
    </div>
    <div class="mws-panel-inner-wrap">
        <div class="mws-panel-body no-padding">
            <div id="DataTables_Table_0_wrapper" class="dataTables_wrapper" role="grid">
	            <form action="/home/seller/goods/index" method="get">
	            	{{ csrf_field() }}
	                <div id="DataTables_Table_0_length" class="dataTables_length">
	                    <label>
	                        显示
	                        <select size="1" name="DataTables_Table_0_length" aria-controls="DataTables_Table_0">
	                            <option value="5" @if(!empty($request['DataTables_Table_0_length']) && $request['DataTables_Table_0_length'] == 5 ) selected @endif>
	                                5
	                            </option>
	                            <option value="10" @if(!empty($request['DataTables_Table_0_length']) && $request['DataTables_Table_0_length'] == 10 ) selected @endif>
	                                10
	                            </option>
	                            <option value="15" @if(!empty($request['DataTables_Table_0_length']) && $request['DataTables_Table_0_length'] == 15 ) selected @endif>
	                                15
	                            </option>
	                            <option value="20" @if(!empty($request['DataTables_Table_0_length']) && $request['DataTables_Table_0_length'] == 20 ) selected @endif>
	                                20
	                            </option>
	                        </select>
	                        条
	                    </label>
	                </div>
	                <div class="dataTables_filter" id="DataTables_Table_0_filter">
	                    <label>
	                        关键字:
	                        <input type="text" aria-controls="DataTables_Table_0" name="search" value="{{ $request['search'] or '' }}">
	                    </label>
	                    <button type="submit" class="btn btn-default"> 搜索 </button>
	                </div>
                </form>
                <div class="dataTables_filter" id="DataTables_Table_0_filter">
	                <a href="/home/seller/goods/index?n=id" @if(empty($request['n'])) style="text-decoration:underline;color:#FF5555" @endif  @if(!empty($request['n']) && $request['n'] == 'id') style="text-decoration:underline;color:#FF5555" @endif style="color:blue"> 默认排序 </a>|
	    			<a href="/home/seller/goods/index?n=price" @if(!empty($request['n']) && $request['n'] == 'price') style="text-decoration:underline;color:#FF5555" @endif style="color:blue"> 价格排序 </a>|
	    			<a href="/home/seller/goods/index?n=sales" @if(!empty($request['n']) && $request['n'] == 'sales') style="text-decoration:underline;color:#FF5555" @endif style="color:blue"> 销量排序 </a>|
	                <a href="/home/seller/goods/index?n=evaulate" @if(!empty($request['n']) && $request['n'] == 'evaulate') style="text-decoration:underline;color:#FF5555" @endif style="color:blue"> 评分排序 </a>|
	    			<a href="/home/seller/goods/index?n=inventory" @if(!empty($request['n']) && $request['n'] == 'inventory') style="text-decoration:underline;color:#FF5555" @endif style="color:blue"> 库存排序 </a>|
	    			<a href="/home/seller/goods/index?n=ctime" @if(!empty($request['n']) && $request['n'] == 'ctime') style="text-decoration:underline;color:#FF5555" @endif style="color:blue"> 时间排序 </a>
    			</div>
                <table class="mws-table mws-datatable dataTable" id="DataTables_Table_0"
                aria-describedby="DataTables_Table_0_info">
                    <thead>
                        <tr role="row">
                            <th class="sorting_asc" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending" style="width: 150px;">
                                商品名称
                            </th>
                            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Browser: activate to sort column ascending" style="width: 100px;">
                                商品头像
                            </th>
                            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Platform(s): activate to sort column ascending" style="width: 100px;">
                                商品价格
                            </th>
                            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 100px;">
                                商品评分
                            </th>
                            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="Engine version: activate to sort column ascending" style="width: 100px;">
                                商品销量
                            </th>
                            <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" style="width: 100px;">
                                商品库存
                            </th>
                             <th class="sorting" role="columnheader" tabindex="0" aria-controls="DataTables_Table_0" rowspan="1" colspan="1" aria-label="CSS grade: activate to sort column ascending" style="width: 160px;">
                                商品上架时间
                            </th>
                            <th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="" style="width: 114px;">
                            	操作
                            </th>
                        </tr>
                    </thead>
                    <tbody role="alert" aria-live="polite" aria-relevant="all">
                    @foreach($data as $v)
                        <tr class="odd" @if($v['status'] == 1) style="background:#F2DEDE" @endif>
                            <td class=" sorting_1">
                                {{ $v['goodsname'] }}
                            </td>
                            <td class=" ">
                                <img src="{{ $v['picture'] }}" onerror="this.src='/goodsupload/goodsphoto/default.gif'" style="width:20px;height:20px" />
                            </td>
                            <td class=" ">
                                ￥{{ $v['price'] }}
                            </td>
                            <td class=" ">
                            	{{ $v['evaulate'] }}
                            </td>
                            <td class=" ">
                           		{{ $v['sales'] }}
                            </td>
                            <td class=" ">
                            	{{ $v['inventory'] }}
                            </td>
                            <td class=" ">
                            	{{ date('Y-m-d H:i:s',$v['ctime']) }}
                            </td>
                            <td class=" ">
                                <span class="btn-group">
                                    <a href="/home/seller/goods/gdetail?id={{ $v['id'] }}" class="btn btn-small" title="详情">
                                        <i class="icon-search"></i>
                                    </a>
                                    <a href="/home/seller/goods/edit?id={{ $v['id'] }}" class="btn btn-small" title="修改" onclick="return confirm('确定修改吗？')">
                                        <i class="icon-pencil"></i>
                                    </a>
                                    @if($v['status'] == 1)
                                    <a href="/home/seller/goods/status?id={{ $v['id'] }}&status=0" class="btn btn-small" title="上架" onclick="return confirm('确定上架吗？')">
                                    	<i class="icon-arrow-up-3"></i>
                                    </a>
                                    @elseif($v['status'] == 0)
                                    <a href="/home/seller/goods/status?id={{ $v['id'] }}&status=1" class="btn btn-small" title="下架" onclick="return confirm('确定下架吗？')">
                                    	<i class="icon-arrow-down-3"></i>
                                    </a>
                                    @endif
                                    <a href="/home/seller/goods/delete?id={{ $v['id'] }}" class="btn btn-small" title="删除" onclick="return confirm('确定删除吗？')">
                                        <i class="icon-trash"></i>
                                    </a>
                                </span>
                            </td>
                        </tr>
                        @endforeach
                    </tbody>
                </table>
                <div class="dataTables_info" id="DataTables_Table_0_info">
                    总共{{ $num }}条
                </div>
                <div id="page_page">
                	{!! $data -> appends($request) -> render() !!}
                </div>
            </div>
        </div>
    </div>
</div>
@endsection